package com.imm.controller;


import com.imm.common.Result;
import com.imm.pojo.ShoppingCart;
import com.imm.service.IShoppingCartService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/shoppingCart")
public class ShoppingCartController {

    @Resource
    private IShoppingCartService shoppingCartService;

    @GetMapping("/list")
    public Result<List<ShoppingCart>> list(ShoppingCart shoppingCart) {
        return shoppingCartService.listShoppingCart(shoppingCart);
    }

    @PostMapping("/add")
    public Result<String> add(@RequestBody ShoppingCart shoppingCart) {
        return shoppingCartService.add(shoppingCart);
    }

    @PostMapping("/sub")
    public Result<String> sub(@RequestBody ShoppingCart shoppingCart) {
        return shoppingCartService.sub(shoppingCart);
    }

    @DeleteMapping("/clean")
    public Result<String> clean() {
        return shoppingCartService.clean();
    }

}
